export default {
    namespaced: true,
    state: {
        isShowToast: false,
        //提示内容
        toastMSG: "",
        //提示类型  success成功 error失败 warning警告
        toastType: "",
    },
    mutations: {
        changeIsShowToast(state, payload) {
            state.isShowToast = payload.isShow;
            //加一个判断让它在有内容的时候才显示，才不会有过度的时候后半部分有个白色的空内容
            if (payload.isShow) {
                state.toastMSG = payload.msg;
                state.toastType = payload.type;
            }
        }
    },
    actions: {
        asyncShowToast(context, payload) {
            context.commit("changeIsShowToast", payload)
            // 2s后自动隐藏
            setTimeout(() => {
                context.commit("changeIsShowToast", {
                    isShow: false
                });
            }, 2000);
        }
    }
}